]> git.r.bdr.sh - rbdr/super-polarity/blame_incremental - Super Polarity/Actors/Bullet.cs
I have the worst commits ever.
[rbdr/super-polarity] / Super Polarity / Actors / Bullet.cs
... / ...
CommitLineData
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using Microsoft.Xna.Framework;
6using Microsoft.Xna.Framework.Graphics;
7
8namespace SuperPolarity
9{
10 class Bullet : Actor
11 {
12 protected ParticleEngine particleEngine;
13 public int Power;
14
15 public Bullet(SuperPolarity newGame)
16 : base(newGame)
17 {
18 }
19
20 ~Bullet()
21 {
22 particleEngine = null;
23 }
24
25 public override void Initialize(Texture2D texture, Vector2 position)
26 {
27 base.Initialize(texture, position);
28 BoxDimensions.X = 10;
29 BoxDimensions.Y = 10;
30 BoxDimensions.W = 10;
31 BoxDimensions.Z = 10;
32 InitBox();
33 particleEngine = ParticleEffectFactory.CreateBullet(position);
34 }
35
36 public override void Update(GameTime gameTime)
37 {
38 Velocity.X = (float)(MaxVelocity * Math.Cos(Angle));
39 Velocity.Y = (float)(MaxVelocity * Math.Sin(Angle));
40
41 Power = 1;
42
43 Position += Velocity;
44 UpdateBox();
45
46 particleEngine.Update();
47 particleEngine.EmitterLocation = Position;
48 }
49
50 public override void Draw(SpriteBatch spriteBatch)
51 {
52 base.Draw(spriteBatch);
53 particleEngine.Draw(spriteBatch);
54 }
55
56 public override void Collide(Actor other, Rectangle collision)
57 {
58 if (Dying) { return; }
59 if (other.GetType().IsAssignableFrom(typeof(StandardShip)))
60 {
61 Die();
62 return;
63 }
64 }
65
66 protected override void Die()
67 {
68 ActorManager.CheckOut(this);
69 Parent.Children.Remove(this);
70 }
71 }
72}